const {src, dest, watch, series, parallel} = require("gulp");
const sass = require("gulp-sass");
const babel = require("gulp-babel");

function jsTransformFn(next){
    src(["www/js/*.js"])
    .pipe(babel({
        presets: ['@babel/env']
    }))
    .pipe(dest("www/dist/js"))
    next();
}
exports.jsTransform = jsTransformFn;
function watchjsTransFn(next){
    watch(["www/js/*.js"],jsTransformFn)
    next();
}
exports.watchjsTrans = watchjsTransFn;
function sassTocssFn(){
    return src(["www/sass/*.scss"])
    .pipe(sass().on("error",sass.logError))
    .pipe(dest("www/dist/css"));
}
function watchSassFn(next){
    watch(["www/sass/*.scss"],sassTocssFn);
    next();
}
exports.ws = watchSassFn;
